

//查询用户
exports.getUser = async (mixnick, cloud) => {

	try {
		let query = `SELECT id as user_id FROM user WHERE mix_nick = '${mixnick}'`;
		let data = await cloudfn(cloud, query);
		return data;
	} catch (err) {
		return err;
	}
}


//加购
exports.addCart = async (params, cloud) => {

	try {
	let query = `insert into user_cart (mix_nick,nick_name, cart_data, sample_data) VALUES
	    ('${params.mixnick}','${params.nickName}', '${params.cart_data}', '${params.sample_data}')`;
		let data = await cloudfn(cloud, query);
		return data;
	} catch (err) {
		return err;
	}
}


cloudfn = async (cloud, sql)=> {
	console.log("==============sql==================", sql)
	let cbData = await cloud.dataspace.executeSql(sql, [])
	console.log("==============cbData==================", cbData)
	return cbData
}




